﻿<%@ Page Title="" Language="C#" MasterPageFile="~/App_SiteMasterPage/layout.Master"
    AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="eProject.Web.UI.DefaultPage" %>

<%@ Register Src="~/Controls/Slider.ascx" TagName="Slider" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="script" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="content" runat="server">
    <asp:ScriptManager ID="ScriptManager" runat="server">
    </asp:ScriptManager>
    <div id="menu" align="center">
        <table width="300px" style="border-top: :1px; border-top-style: solid; border-top-color: #1D64A4"
            align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    Origin
                </td>
                <td>
                    Destination
                </td>
            </tr>
            <tr>
                <td>
                    <asp:DropDownList ID="ddlOrigin" runat="server" Width="127" ValidationGroup="bookingFlight"
                        CssClass="inputText" AutoPostBack="true" />
                    <div>
                        <asp:CustomValidator ID="cusOrigin" runat="server" CssClass="ddlError" ClientValidationFunction="cusOrigin_ClientValidate"
                            ErrorMessage="Select Origin." ValidationGroup="bookingFlight" Display="Dynamic" />
                    </div>
                </td>
                <td>
                    <asp:UpdatePanel ID="upnlDestination" runat="server">
                        <ContentTemplate>
                            <asp:DropDownList ID="ddlDestination" runat="server" Width="127" Enabled="false"
                                CssClass="inputText-disabled" />
                            <div>
                                <asp:CustomValidator ID="cusDestination" runat="server" CssClass="ddlError" ClientValidationFunction="cusDestination_ClientValidate"
                                    ErrorMessage="Origin can't equal Destination." ValidationGroup="bookingFlight"
                                    Display="Dynamic" />
                            </div>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="ddlOrigin" EventName="SelectedIndexChanged" />
                        </Triggers>
                    </asp:UpdatePanel>
                </td>
            </tr>
            <tr>
                <td>
                    Departing
                </td>
                <td>
                    Returning
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="txtdepart" runat="server" placeholder="dd/mm/yyyy" ValidationGroup="bookingFlight"
                        Width="125" CssClass="inputText" />
                    <div>
                        <asp:RequiredFieldValidator ID="rfvDepart" ControlToValidate="txtdepart" Display="Dynamic"
                            CssClass="ddlError" ValidationGroup="bookingFlight" runat="server" ErrorMessage="Insert departing date" /></div>
                </td>
                <td>
                    <asp:TextBox ID="txtreturn" runat="server" placeholder="dd/mm/yyyy" ValidationGroup="bookingFlight"
                        Width="125" CssClass="inputText" />
                    <div>
                        <asp:CustomValidator ID="cusReturn" runat="server" CssClass="ddlError" ClientValidationFunction="cusReturn_ClientValidate"
                            ErrorMessage="Insert returning date." ValidationGroup="bookingFlight" Display="Dynamic" />
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:RadioButton ID="rdOneWay" GroupName="route" runat="server" Checked="true" Text="One Way" />
                </td>
                <td>
                    <asp:RadioButton ID="rdRoundTrip" GroupName="route" runat="server" Text="Round Trip" />
                </td>
            </tr>
        </table>
        <p>
            &nbsp;</p>
        <hr align="center" width="270" />
        <p>
            &nbsp;</p>
        <table width="280" style="border-bottom: :1px; border-bottom-style: solid; border-bottom-color: #1D64A4"
            align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td width="79">
                    Adult <font color="#666666">12+</font>
                </td>
                <td width="89">
                    <span>Children<font color="#666666"> 2-11</font></span>
                </td>
                <td width="96">
                    <span>Infant <font color="#666666">below 2</font></span>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:DropDownList ID="ddlAdult" runat="server" ValidationGroup="bookingFlight" Width="60"
                        CssClass="inputText" />
                </td>
                <td>
                    <asp:DropDownList ID="ddlChildren" runat="server" ValidationGroup="bookingFlight"
                        Width="60" CssClass="inputText" />
                </td>
                <td>
                    <asp:DropDownList ID="ddlInfant" runat="server" ValidationGroup="bookingFlight" Width="60"
                        CssClass="inputText" />
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    &nbsp;
                </td>
                <td>
                    <asp:Button ID="btnSearchFlight" runat="server" ValidationGroup="bookingFlight" CssClass="searchFlight" />
                </td>
            </tr>
        </table>
    </div>
    <!-- ket thuc phan mene -->
    <div id="search">
        <div id="slider" class="slider">
            <uc1:Slider ID="Slider" runat="server" />
        </div>
    </div>
    <script type="text/javascript" language="javascript">

        function cusOrigin_ClientValidate(sender, args) {
            var from = $('#<%=ddlOrigin.ClientID%>');
            if (from.val() == "-1") {
                sender.errormessage = "Please choose Origin.";
                args.IsValid = false;
            }
            else
                args.IsValid = true;
        }
        function cusDestination_ClientValidate(sender, args) {
            var from = $('#<%=ddlOrigin.ClientID%>');
            var to = $('#<%=ddlDestination.ClientID%>');
            if (from.val() == to.val()) {
                sender.errormessage = "Origin can't equal Destination.";
                args.IsValid = false;
            }
            else if (to.val() == "-1") {
                sender.errormessage = "Please choose Destination.";
                args.IsValid = false;
            }
            else
                args.IsValid = true;
        }

        function cusReturn_ClientValidate(sender, args) {
            if ($("#<%=rdRoundTrip.ClientID %>").attr('checked')) {
                var txtreturn = $('#<%=txtreturn.ClientID%>');
                if (txtreturn.val() == "") {
                    sender.errormessage = "Insert return date.";
                    args.IsValid = false;
                } else
                    args.IsValid = true;
            }
            else
                args.IsValid = true;
        }

        $(function () {
            $("#<%=txtdepart.ClientID %>").datepicker({
                dateFormat: "dd/mm/yy",
                minDate: 0,
                maxDate: "+2M",
                changeMonth: true,
                numberOfMonths: 3,
                showOn: "both",
                buttonImage: "/Images/Icons/calendar.gif",
                buttonImageOnly: true,
                onSelect: function (selectedDate) {
                    $("#<%=txtreturn.ClientID %>").datepicker("option", "minDate", selectedDate);
                }
            });

            $("#<%=txtreturn.ClientID %>").datepicker({
                dateFormat: "dd/mm/yy",
                minDate: 0,
                maxDate: "+2M",
                changeMonth: true,
                numberOfMonths: 3,
                showOn: "both",
                buttonImage: "/Images/Icons/calendar.gif",
                buttonImageOnly: true,
                onSelect: function (selectedDate) {
                    $("#<%=txtdepart.ClientID %>").datepicker("option", "maxDate", selectedDate);
                }
            });



            if ($("#<%=rdOneWay.ClientID %>").attr('checked')) {
                $("#<%=txtreturn.ClientID %>").attr('class', 'inputText-disabled');
                $("#<%=txtreturn.ClientID %>").attr('disabled', 'disabled');
            }
            $("#<%=rdOneWay.ClientID %>").change(function () {
                if ($("#<%=rdOneWay.ClientID %>").attr('checked')) {
                    $("#<%=txtreturn.ClientID %>").attr('class', 'inputText-disabled');
                    $("#<%=txtreturn.ClientID %>").attr('disabled', 'disabled');
                }
            });

            if ($("#<%=rdRoundTrip.ClientID %>").attr('checked')) {
                $("#<%=txtreturn.ClientID %>").attr('class', 'inputText');
                $("#<%=txtreturn.ClientID %>").removeAttr('disabled');
            }
            $("#<%=rdRoundTrip.ClientID %>").change(function () {
                if ($("#<%=rdRoundTrip.ClientID %>").attr('checked')) {
                    $("#<%=txtreturn.ClientID %>").attr('class', 'inputText');
                    $("#<%=txtreturn.ClientID %>").removeAttr('disabled');
                }
            });

            $("#<%=txtdepart.ClientID %>").mask("99/99/9999");
            $("#<%=txtreturn.ClientID %>").mask("99/99/9999");
        });
    </script>
</asp:Content>
